home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DEMOS / FLC-BUMP.ZIP / BUMP2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-13  |  2.4 KB  |  169 lines

  1. {$A+,B-,D-,E-,F-,G+,I+,L-,N-,O-,P-,Q-,R-,S-,T-,V+,X+}
  2. {$M 16384,0,655360}
  3. uses mouse;
  4. type nimage = Array[0..65534] of Byte;
  5. Var
  6. map              : ^nimage;
  7. c,celine         : pointer;
  8. f                : file;
  9. x,y,coul         : integer;
  10. compt            : integer;
  11. pal              : array[0..767] of byte;
  12. i                : integer;
  13. cx,cy            : integer;
  14.  
  15.  
  16. Procedure Lumiere (PosX,Posy : word); Assembler;
  17. var
  18. lx,ly   : integer;
  19. i,j,coul1,coul2  : integer;
  20.   asm
  21.   mov di,321
  22.  
  23.   mov ax,1
  24.   sub ax,posy
  25.   mov ly,ax
  26.  
  27.   mov i,198
  28.   @boucle_Y:
  29.  
  30.     mov ax,1
  31.     sub ax,posx
  32.     mov lx,ax
  33.  
  34.     mov j,318
  35.     @boucle_X:
  36.  
  37.      mov ax, word ptr map[2]
  38.      mov es,ax
  39.  
  40.      xor bx,bx
  41.  
  42.      xor ax,ax
  43.      mov al,es:[di+1]
  44.      mov bl,es:[di-1]
  45.      sub ax,bx
  46.      mov x,ax
  47.  
  48.      xor ax,ax
  49.      mov al,es:[di+320]
  50.      mov bl,es:[di-320]
  51.      sub ax,bx
  52.      mov y,ax
  53.  
  54.      inc lx
  55.  
  56.      mov ax,x  {calcul de coul1:x}
  57.      sub ax,lx
  58.      cwd       {abs(ax)}
  59.      xor ax,dx
  60.      sub ax,dx
  61.      mov bx,128
  62.      sub bx,ax
  63.      cmp bx,0
  64.      jg  @lapin
  65.      mov bx,0
  66.     @lapin:
  67.  
  68.      mov ax,y  {coul2}
  69.      sub ax,ly
  70.      cwd
  71.      xor ax,dx
  72.      sub ax,dx
  73.      mov cx,128
  74.      sub cx,ax
  75.      cmp cx,0
  76.      jg @elephant
  77.      mov cx,0
  78.     @elephant:
  79.  
  80.      mov ax,bx {coul1*coul2}
  81.      mul cx
  82.      mov bx,64
  83.      div bx
  84.      cmp ax,255
  85.      jbe @girafe
  86.      mov ax,255
  87.     @girafe:
  88.      mov bx,word ptr celine[2]
  89.      mov es,bx
  90.      mov es:[di],al
  91.      inc di
  92.  
  93.    dec j
  94.    jnz @boucle_X
  95.  
  96.   inc ly
  97.  
  98.   add di,2
  99.   dec i
  100.   jnz @boucle_Y
  101.   end;
  102.  
  103. Procedure WaitRetrace; assembler;
  104. asm
  105.   mov dx,3dah
  106. @wait1:
  107.   in al,dx
  108.   test al,08h
  109.   jnz @wait1
  110.  
  111. @wait2:
  112.   in al,dx
  113.   test al,08h
  114.   jz @wait2
  115. end;
  116.  
  117. procedure CopyScreen ; assembler;
  118. asm
  119. push ds
  120. mov ax,0A000H
  121. mov es,ax
  122. xor di,di
  123. lds si,celine
  124. mov cx,16000
  125. db 66H; rep movsw
  126. pop ds
  127. end;
  128.  
  129.  
  130. Begin
  131. c:=ptr($a000,0);
  132. New(map);
  133. getmem(celine,64000);
  134.  
  135. asm
  136. mov ax,13h
  137. int 10h
  138.  
  139. db 66H; xor ax,ax
  140. les di,celine
  141. mov cx,16000
  142. db 66H; rep stosw
  143.  
  144. end;
  145. assign(f,'bump.img');
  146. reset(f,1);
  147. blockread(f,map^,64000);
  148. close(f);
  149.  
  150. port[$3C8]:=0;
  151. for i:=0 to 767 do port[$3C9]:=i*(i mod 3) div 24;
  152.  
  153.  
  154. compt:=0;
  155.  
  156.  
  157. repeat
  158. Lumiere(mousegetposx shr 1,mousegetposy);
  159. WaitRetrace;
  160. copyscreen;
  161. inc(compt);
  162. until (port[$60]<$80) or (mouseleft) ;
  163.  
  164. asm
  165. mov ax,3h
  166. int 10h
  167. end;
  168. End.
  169.